@echo off
chcp 65001
setlocal enabledelayedexpansion

set buildType=%1
set projectPath=C:\mateurp_pipline\mateurp_ios\mateurp
set curr_buildIdFile=%projectPath%\Build\build_id_%buildType%.txt
set /p curr_buildId=<%curr_buildIdFile%

set XCodeFileNameOrgin=mate_ios_%buildType%.zip
set XCodeFileName=mate_ios_%buildType%_%curr_buildId%.zip
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /R "IPv4"') do (
    set ip=%%i
)
set ip=%ip:~1%
set downloadUrl=http://%ip%/

if "%buildType%"=="DEBUG" (
    copy /Y %projectPath%\Build\IOS\RELEASE\output_xcode.zip C:\mateurp_pipline\Mate\%XCodeFileName%
)

if "%buildType%"=="RELEASE" (
    copy /Y %projectPath%\Build\IOS\RELEASE\output_xcode.zip C:\mateurp_pipline\Mate\%XCodeFileName%
)


copy /Y  C:\mateurp_pipline\Mate\%XCodeFileName% C:\mateurp_pipline\Mate\%XCodeFileNameOrgin%

echo downloadUrl: %downloadUrl%%XCodeFileName%
echo %XCodeFileName% upload finish

set json="{\"text\":{\"content\":\"本地IOS打包完成,下载地址 %downloadUrl%%XCodeFileName% or %downloadUrl%%XCodeFileNameOrgin% \" },\"msgtype\":\"text\"}"
echo %json%
curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d !json! https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8
endlocal